gboolean
ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GError **error)
{
- gboolean ret = FALSE;
g_autoptr(GOptionContext) context = NULL;
glnx_unref_object OstreeSysroot *sysroot = NULL;
const char *deploy_index_str;
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
&sysroot, cancellable, error))
- goto out;
+ return FALSE;
if (argc < 2)
{
ot_util_usage_error (context, "INDEX must be specified", error);
- goto out;
+ return FALSE;
}
if (!ostree_sysroot_load (sysroot, cancellable, error))
- goto out;
+ return FALSE;
current_deployments = ostree_sysroot_get_deployments (sysroot);
deploy_index_str = argv[1];
target_deployment = ot_admin_get_indexed_deployment (sysroot, deploy_index, error);
if (!target_deployment)
- goto out;
+ return FALSE;
if (target_deployment == ostree_sysroot_get_booted_deployment (sysroot))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"Cannot undeploy currently booted deployment %i", deploy_index);
- goto out;
+ return FALSE;
}
-
+
g_ptr_array_remove_index (current_deployments, deploy_index);
if (!ostree_sysroot_write_deployments (sysroot, current_deployments,
cancellable, error))
- goto out;
+ return FALSE;
g_print ("Deleted deployment %s.%d\n", ostree_deployment_get_csum (target_deployment),
ostree_deployment_get_deployserial (target_deployment));
-
+
if (!ostree_sysroot_cleanup (sysroot, cancellable, error))
- {
- g_prefix_error (error, "Performing final cleanup: ");
- goto out;
- }
+ return g_prefix_error (error, "Performing final cleanup: "), FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
OstreeDeployment *booted_deployment =
ostree_sysroot_get_booted_deployment (sysroot);
-
if (booted_deployment == NULL && osname == NULL)
- {
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Not currently booted into an OSTree system and no --os= argument given");
- goto out;
- }
-
- ret = TRUE;
- out:
- return ret;
+ return glnx_throw (error, "Not currently booted into an OSTree system and no --os= argument given");
+ return TRUE;
}
/**
g_source_set_callback (timeout_src, (GSourceFunc)on_sysroot_lock_timeout, &state, NULL);
g_source_attach (timeout_src, state.mainctx);
g_source_unref (timeout_src);
-
+
on_sysroot_lock_timeout (&state);
ostree_sysroot_lock_async (sysroot, NULL, (GAsyncReadyCallback)on_sysroot_lock_acquired, &state);
ot_admin_execve_reboot (OstreeSysroot *sysroot, GError **error)
{
g_autoptr(GFile) real_sysroot = g_file_new_for_path ("/");
-
+
if (g_file_equal (ostree_sysroot_get_path (sysroot), real_sysroot))
{
if (execlp ("systemctl", "systemctl", "reboot", NULL) < 0)
- {
- glnx_set_error_from_errno (error);
- return FALSE;
- }
+ return glnx_throw_errno (error);
}
return TRUE;
GError **error)
{
glnx_unref_object OstreeRepo *repo = NULL;
- gboolean success = FALSE;
/* Entries are listed in --help output in the order added. We add the
* main entries ourselves so that we can add the --repo entry first. */
{
g_propagate_error (error, g_steal_pointer (&local_error));
}
- goto out;
+ return FALSE;
}
}
else if (opt_repo != NULL)
if (!(flags & OSTREE_BUILTIN_FLAG_NO_CHECK))
{
if (!ostree_repo_open (repo, cancellable, error))
- goto out;
+ return FALSE;
}
}
if (out_repo)
*out_repo = g_steal_pointer (&repo);
- success = TRUE;
-
-out:
- return success;
+ return TRUE;
}
gboolean
GCancellable *cancellable,
GError **error)
{
- g_autoptr(GFile) sysroot_path = NULL;
- glnx_unref_object OstreeSysroot *sysroot = NULL;
- gboolean success = FALSE;
-
/* Entries are listed in --help output in the order added. We add the
* main entries ourselves so that we can add the --sysroot entry first. */
g_option_context_add_main_entries (context, global_admin_entries, NULL);
if (!ostree_option_context_parse (context, main_entries, argc, argv, OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, error))
- goto out;
+ return FALSE;
+ g_autoptr(GFile) sysroot_path = NULL;
if (opt_sysroot != NULL)
sysroot_path = g_file_new_for_path (opt_sysroot);
- sysroot = ostree_sysroot_new (sysroot_path);
+ glnx_unref_object OstreeSysroot *sysroot = ostree_sysroot_new (sysroot_path);
if (flags & OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER)
{
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
"You must be root to perform this command");
- goto out;
+ return FALSE;
}
}
g_autofree char *deployment_path = NULL;
if (!ostree_sysroot_load (sysroot, cancellable, error))
- goto out;
+ return FALSE;
deployments = ostree_sysroot_get_deployments (sysroot);
if (deployments->len == 0)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Unable to find a deployment in sysroot");
- goto out;
- }
+ return glnx_throw (error, "Unable to find a deployment in sysroot");
first_deployment = deployments->pdata[0];
deployment_file = ostree_sysroot_get_deployment_directory (sysroot, first_deployment);
deployment_path = g_file_get_path (deployment_file);
{
/* Released when sysroot is finalized, or on process exit */
if (!ot_admin_sysroot_lock (sysroot, error))
- goto out;
+ return FALSE;
}
if (out_sysroot)
*out_sysroot = g_steal_pointer (&sysroot);
- success = TRUE;
-
-out:
- return success;
+ return TRUE;
}
gboolean
ostree_ensure_repo_writable (OstreeRepo *repo,
GError **error)
{
- gboolean ret;
-
- ret = ostree_repo_is_writable (repo, error);
-
- g_prefix_error (error, "Cannot write to repository: ");
-
- return ret;
+ if (!ostree_repo_is_writable (repo, error))
+ return g_prefix_error (error, "Cannot write to repository: "), FALSE;
+ return TRUE;
}
void
gboolean
ot_enable_tombstone_commits (OstreeRepo *repo, GError **error)
{
- gboolean ret = FALSE;
gboolean tombstone_commits = FALSE;
GKeyFile *config = ostree_repo_get_config (repo);
{
g_key_file_set_boolean (config, "core", "tombstone-commits", TRUE);
if (!ostree_repo_write_config (repo, config, error))
- goto out;
+ return FALSE;
}
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}